package com.baitiaojun.video.api;

import com.baitiaojun.api.domain.video.Video;
import com.baitiaojun.api.domain.video.VideoView;
import com.baitiaojun.api.exception.ConditionException;
import com.baitiaojun.api.util.ConstantUtil;
import com.baitiaojun.api.vo.JsonRes;
import com.baitiaojun.api.vo.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @类名 VideoApi
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2022/12/19 14:33
 * @版本 1.0
 */
@Api("视频接口")
@RequestMapping("/video")
public interface VideoApi {

    /**
     * 添加视频
     */
    @ApiOperation("添加视频信息")
    @PostMapping("/new-video")
    JsonRes addVideo(@ApiParam(value = "视频信息", required = true) @RequestBody Video video) throws Exception;

    /**
     * 获取视频分区
     */
    @ApiOperation("获取视频分区")
    @GetMapping("/video-area")
    JsonRes getVideoArea();

    /**
     * 分区查看视频
     */
    @ApiOperation("分区分页查看视频")
    @GetMapping("/area-videos")
    PageInfo getPageAreaListVideos(@ApiParam(value = "当前返回的最后一个数据的id") Long lastId
            , @ApiParam(value = "每页显示条数", example = "10") @RequestParam(defaultValue = ConstantUtil.AREA_VIDEO_PAGE_SIZE) Integer pageSize
            , @ApiParam(value = "视频分区", required = true) @RequestParam String area) throws IOException;

    /**
     * 视频点赞
     */
    @ApiOperation("添加视频点赞")
    @PostMapping("/new-video-like")
    JsonRes addVideoLike(@ApiParam(value = "视频id", required = true) @RequestParam Long videoId) throws Exception;

    @ApiOperation("取消视频点赞")
    @DeleteMapping("/cancel-video-like")
    JsonRes cancelVideoLike(@ApiParam(value = "视频id", required = true) @RequestParam Long videoId) throws Exception;

    @ApiOperation("查看视频点赞")
    @GetMapping("/video-like")
    JsonRes getVideoLike(@ApiParam(value = "视频id", required = true) @RequestParam("videoId") Long videoId) throws Exception;

    /**
     * 视频收藏
     */
    @ApiOperation("添加视频收藏")
    @PostMapping("/new-video-collection")
    JsonRes addVideoCollection(@ApiParam(value = "视频id", required = true) @RequestParam Long videoId, @ApiParam(value = "分组id") Long groupId) throws Exception;

    @ApiOperation("取消视频收藏")
    @DeleteMapping("/cancel-video-collection")
    JsonRes cancelVideoCollection(@ApiParam(value = "视频id", required = true) @RequestParam Long videoId) throws Exception;

    @ApiOperation("查看视频收藏")
    @GetMapping("/video-collection")
    JsonRes getVideoCollection(@ApiParam(value = "视频id", required = true) @RequestParam("videoId") Long videoId) throws Exception;

    /**
     * 视频投币
     */
    @ApiOperation("添加视频投币")
    @PostMapping("/video-coin-operation")
    JsonRes videoCoinOperated(@ApiParam(value = "投币个数", required = true, example = "1") @RequestParam Integer coinOperated
            , @ApiParam(value = "视频id", required = true) @RequestParam Long videoId) throws Exception;

    @ApiOperation("查看视频投币")
    @GetMapping("/video-coin")
    JsonRes getVideoCoins(@ApiParam(value = "视频id", required = true) @RequestParam Long videoId);

    /**
     * 视频详情
     */
    @ApiOperation("查看视频详情")
    @GetMapping("/video-details")
    JsonRes getVideoDetails(@ApiParam(value = "视频id", required = true) @RequestParam Long videoId) throws Exception;

    /**
     * 视频被观看次数
     */
    @ApiOperation("新增视频观看记录")
    @PostMapping("/new-video-view")
    JsonRes addVideoViewCount(@ApiParam(value = "视频观看实体", required = true) @RequestBody VideoView videoView) throws ConditionException;

    @ApiOperation("查看视频观看记录")
    @GetMapping("video-view")
    JsonRes getVideoViewCount(@ApiParam(value = "视频id", required = true) @RequestParam("videoId") Long videoId);

    /**
     * 视频推荐
     */
    @ApiOperation(value = "查看视频推荐", hidden = true)
    @GetMapping("/recommend")
    JsonRes recommend() throws Exception;

    /**
     * 查询首页瀑布流
     */
    @ApiOperation("查看主页视频列表")
    @GetMapping("/home-page-video")
    JsonRes getHomePageVideo(@ApiParam(value = "当前返回的最后一个数据的id") Long lastId
                            , @ApiParam(value = "总页数", example = "10") @RequestParam(defaultValue = ConstantUtil.HOME_VIDEO_PAGE_SIZE) Integer pageSize) throws Exception;

    @ApiOperation(value = "删除视频相关记录", hidden = true)
    @DeleteMapping("/cancel-video")
    void removeVideo(@RequestParam("videoId") Long videoId) throws ConditionException;
}